#include <xscript/xfilereader.h>

XFileReader::~XFileReader() {
    if (stream.is_open())
        stream.close();
}

bool XFileReader::open(const std::string& file) {
    if (stream.is_open())
        stream.close();
    stream.open(file.data());
    return stream.is_open();
}

std::wstring XFileReader::readLine() {
    static wchar_t buffer[1024] = {0};
    stream.getline(buffer, 1024);
    return std::wstring(buffer);
}

bool XFileReader::eof() const {
    return stream.eof();
}
